﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;


using EMC;

using DatabaseModule;

using System.IO;
using System.Reflection;

namespace EMCTestSuite
{
    class Program
    {
        static void Main(string[] args)
        {
            //Retrieves the application's directory, from <http://www.csharp-examples.net/get-application-directory/>
            string dbConfigFile = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Program)).CodeBase) + @"/db_settings.xml";
            databaseConfiguration config = new databaseConfiguration(dbConfigFile);

            //##########################UNIT USER TEST#######################################
            //UserManagement userman = new UserManagement(config);
            //add a user
            //userman.adduser("billfred", "bill", "fred", "pass", "0401 636 230","bob@bill.com.au");

            //edit a user
            //userman.editUser("billfred", "bob", "bill", null, "0449 034 324", "bill@google.com");

            //get a users Details
            /*
             foreach (var pair in userman.GetUser("billfred"))
            {
                 Console.WriteLine("{0}, {1}",pair.Key,pair.Value);
            }
              */
            //check if a user exists
            //Console.WriteLine(userman.userExists("dave"));

            //get the password of a user
            //Console.WriteLine(userman.GetUserPassword("dave"));

            //check if a user can authenticate
            //Console.WriteLine(userman.authenticateUser("dave",userman.GetUserPassword("dave")));

            //delete all trace of user WARNING 
            //userman.delUser("dave");

            //##########################UNIT FRIENDS TEST#######################################
            //FriendManagement friendman = new FriendManagement(config);
            //check for friends
            //Console.WriteLine(friendman.checkfriend("dave", "billfred"));
            //add friends to a user
            //Console.WriteLine(friendman.addfriend("dave", "billfred"));
            //Console.WriteLine(friendman.addfriend("bill", "bob"));
            //Console.WriteLine(friendman.addfriend("bill", "jill"));
            //Console.WriteLine(friendman.addfriend("bill", "ted"));
            //Console.WriteLine(friendman.addfriend("bill", "station"));
            //Console.WriteLine(friendman.addfriend("ted", "bill"));
            //Console.WriteLine(friendman.addfriend("bob", "adam"));

            //list friends 
            /*
            foreach (string user in friendman.ListFriends("dave"))
            {
                Console.WriteLine(user);
            }
            */
            //remove a friend
            //Console.WriteLine(friendman.removefriend("jill","bill"));

            //##########################UNIT FILE TEST#######################################
            FileManagement fileman = new FileManagement(config);
            Console.WriteLine("Files");
            ////add a file
            //fileman.addfile("myfile", "this is a file", "dave");
            //fileman.addfile("myfileII", "this is a file", "dave");
            //fileman.addfile("myfileIII", "this is a file", "dave");


            //foreach (string i in fileman.getfiles())
            //{
            //    Console.WriteLine(i);
            //}
            foreach (KeyValuePair<string, string> kvp in fileman.getallfiledata())
            {
                Console.WriteLine("Key: " + kvp.Key + " Value: " + kvp.Value);
            }



            //edit a file
            //Console.WriteLine(fileman.editFile("myfile", "bob", "dave", "bob"));

            //list all file for a user
            //Console.WriteLine(fileman.userFiles("dave"));
            /*
             * 
            foreach (string i in fileman.userFiles("dave"))
            {
                Console.WriteLine(i);
            }
            */
            //delete a file from a user 
            //Console.WriteLine(fileman.removeFile("dave","myfile"));
            Console.ReadKey();
        }
    }
}
